package com.sxt.bus.utils;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author WanMing
 * @date 2019/2/8 10:26
 */

public class MobileNumberUtils {


    /**
     * 生成连续手机号码
     * @param strNumber
     * @param endNumber
     * @return
     */
    public static List<String> createMobileNumber(Long strNumber,Long endNumber){
        List<String> list = new ArrayList<>();
        for(Long i=strNumber;i<=endNumber;i++){
            list.add(i+"");
        }
        return list;
    }

    /**
     * 生成length位随机不重复卡号
     * @param length
     * @return
     */
    public static String getStringRandom(int length) {
        String val = "";
        Random random = new Random();
        // length为几位密码
        for (int i = 0; i < length; i++) {
            // 判断生成数字还是字母(字母有大小写区别)
            String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
            // 输出字母还是数字
            if ("char".equalsIgnoreCase(charOrNum)) {
                // 输出是大写字母还是小写字母
                int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
                val += (char) (random.nextInt(26) + temp);
            } else if ("num".equalsIgnoreCase(charOrNum)) {
                val += String.valueOf(random.nextInt(10));
            }
        }
        return val.toUpperCase();
    }



}
